package com.balance.controller.regist;

import com.balance.pojo.LoginDTO;
import com.balance.pojo.common.CommonResult;
import com.balance.pojo.sys.SysUser;
import com.balance.service.regist.IRegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Title: UserRegister
 * @Author 小东
 * @Package com.balance.controller.regist
 * @Date 2025/4/1 15:20
 * @description: 用户注册接口
 */
@RestController
@RequestMapping("login")
public class UserRegister {

    @Autowired
    private IRegisterService iRegisterService;

    /**
     * 获取验证码
     * @param phone：电话号
     * @param
     * @return
     */
    @GetMapping("/register")
    public CommonResult<String> checkPhoneAndCode(@RequestParam String phone){
        return iRegisterService.checkPhoneAndCode(phone);
    }

    /**
     * 使用账号登录接口
     * @param sysUser：账号密码信息
     * @return
     */
    @PostMapping("/loginByCount")
    public CommonResult<String> checkUsernameAndPwd(@RequestBody SysUser sysUser){
        return iRegisterService.checkUsernameAndPwd(sysUser);
    }

    /**
     * 使用手机号登录
     * @param loginDTO：请求体的手机号和验证码
     * @return
     */
    @PostMapping("/loginByPhone")
    public CommonResult<String> checkByCode(@RequestBody LoginDTO loginDTO){
        return iRegisterService.checkPhoneCode(loginDTO);
    }
}
